<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      ul {
        list-style: none;
        padding-top: 15px;
      }
      .box {
        width: 350px;
        height: 420px;
        border: 1px solid #000;
        margin: 100px auto;
      }
      li {
        float: left;
        width: 20%;
        text-align: center;
      }
      img:hover {
        outline: 3px solid #0094ff;
      }
    </style>
  </head>
  <body>
    <div class="box">
      <div>
        <img src="images/b1.jpg" id="big" alt="" />
      </div>
      <div>
        <ul id="ul">
          <!--data-src是自定义属性，存放对应大图的src-->
          <li data-src="images/b1.jpg"><img src="images/s1.jpg" alt="" /></li>
          <li data-src="images/b2.jpg"><img src="images/s2.jpg" alt="" /></li>
          <li data-src="images/b3.jpg"><img src="images/s3.jpg" alt="" /></li>
          <li data-src="images/b4.jpg"><img src="images/s4.jpg" alt="" /></li>
          <li data-src="images/b5.jpg"><img src="images/s5.jpg" alt="" /></li>
        </ul>
      </div>
    </div>
  </body>
  <script>
    //写入口函数
    window.onload = function () {
      const lis = document.querySelectorAll("li");
      const big = document.querySelector("#big");
      lis.forEach(function (item) {
        item.onmouseover = function () {
          console.log(item.dataset.src);
          big.src = item.dataset.src;
        };
      });
    };
  </script>
</html>
